import Vue from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import ElementUI from 'element-ui';
import * as echarts from 'echarts/lib/echarts';
import 'element-ui/lib/theme-chalk/index.css';
// import '@/styles/normalize.css';
import '@/styles/reset.css';
import '@/styles/public.scss';
import dataV from '@jiaminghi/data-view';
import CustomSource from '@/CustomSource/CustomSource';

Vue.use(dataV);
Vue.use(CustomSource);
Vue.config.productionTip = false;
Vue.prototype.$echarts = echarts;
Vue.use(ElementUI, { size: 'small' });

resizeRem(document, window);
new Vue({
	router,
	store,
	render: h => h(App),
}).$mount('#app');

// 根据屏幕宽度设置根元素字体大小
function resizeRem(doc, win) {
	let docEl = doc.documentElement;
	let resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize';
	let recalc = function () {
		let clientWidth = docEl.clientWidth;
		if (!clientWidth) return;
		if (clientWidth === 4000) {
			clientWidth = 2400;
		}
		docEl.style.fontSize = 16 * (clientWidth / 1920) + 'px';
	};
	if (!doc.addEventListener) return;
	recalc();
	win.addEventListener(resizeEvt, recalc, false);
	doc.addEventListener('DOMContentLoaded', recalc, false);
}
